<template>
    <view class="page-create-draft">
        <view class="py-4" v-if="longList.list.length == 0">
                <u-empty text="暂无数据" mode="list"></u-empty>
        </view>
        <view class="fly-card" v-else>
            <view class="item" v-for="(item,index) in longList.list" :key="index" @click="proxy.$util.gotoPage('/pages/create/index',{id:item.id})">
                <view class="thumb">
                    <u-image width="100%" height="300rpx" :src="proxy.$icon.cover1"></u-image>
                </view>
                <view class="content">
                    <view class="title font-bold ellipsis-1">{{ item.activitiesName }}</view>
                    <view class="desc mt-2">
                        <view>时间：<text class="c-black">{{ dayjs(item.startTime).format('MM/DD HH:mm') }} {{ proxy.$util.getWeekName(dayjs(item.startTime).day()) }}</text></view>
                        <view class="ellipsis-1">地点：<text class="c-black">{{ item.address }}</text></view>
                        <view>报名人数：<text class="c-black">{{ item.maxParticipants }}</text></view>
                    </view>
                    <view class="mt-2">
                        <u-button class="btn-cyan" shape="circle" size="mini" @click.stop="handleDelete(item)"><u-icon name="trash" color="#fff"></u-icon><text class="ml-1">删除</text></u-button>
                    </view>
                </view>
            </view>
        </view>
    </view>
</template>
<script setup lang="ts">
import dayjs from 'dayjs';
import {onShow, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app';
import { useLonglist } from '@/static/fn/longList';
const initObj = {
	listApi:'/admin/activities/xcxPage',
}
let { searchForm, longList, getList} = useLonglist(initObj);
const {proxy} = getCurrentInstance() as ComponentInternalInstance;
const handleDelete = (item) => {
    uni.showModal({
        title: '提示',
        content: '是否要删除该活动',
        success: res => {
            if(res.confirm){
                proxy.$http('delete', '/admin/activities', [item.id], (data,msg) => {
                    getList('refresh');
                })
            }
        },
        
    })
}
onPullDownRefresh(() => {
	getList('refresh');
	setTimeout( () => {
		uni.stopPullDownRefresh();
	}, 1000);
});
onReachBottom(() =>{
    console.log('底部加载')
	getList();
});
onShow(() => {
    searchForm.status = 0;
    getList('refresh');
})
</script>